home *** CD-ROM | disk | FTP | other *** search
/ ASME's Mechanical Engine…ing Toolkit 1997 December / ASME's Mechanical Engineering Toolkit 1997 December.iso / c_lang / tcwindow.lzh / WINDOW.C < prev    next >
Encoding:
C/C++ Source or Header  |  1987-12-05  |  53.4 KB  |  1,109 lines

  1. /****************************************************************************/
  2. /* These procedures are used to create windows,write,and clear.             */
  3. /* I use windows in my programs and TurboC did not support them.            */
  4. /* The routines can be used by you but if you use them I only ask           */
  5. /* that I get a little credit for my work.                                  */
  6. /* This is my first real program in C if you find bugs let me know thanks.  */
  7. /*   writted by                                                             */
  8. /*   Charles G. Nemer                                                       */
  9. /*   4538 Westlake Dr.                                                      */
  10. /*   Garlend TX. 75043                                                      */
  11. /*   214-226-9364                                                           */
  12. /****************************************************************************/
  13.  
  14. #include<stdio.h>
  15. #include<alloc.h>
  16. #include<dos.h>
  17. #include<stdarg.h>
  18.  
  19. #define MONO 0xB0000000                                    /* address of mono screen*/
  20. #define COLORM 0XB8000000                                  /* address of color screen*/
  21. #define TRUE -1
  22. #define FALSE 0
  23.  
  24. union REGS reg;struct SREGS sreg;                          /* setup struct for DOS registrrs */
  25.  
  26. struct  window_data{                                       /* struct so save window info*/
  27.           unsigned short wrowb,wcolb,wrowe,wcole,wpage,wmode,
  28.                          wcurr,wcurc,wcolor,wnum_col,
  29.                          bd,bdcolor,wnumber;
  30.                     unsigned int  size;
  31.                     int far * addressave;
  32.                     int far *screenbase;
  33.                     struct window_data far *last,far *next;
  34.                     };
  35.  
  36.  
  37. int far *screenbase,far *fscreenbase;                      /*  start of screen*/
  38.  
  39. unsigned short row,rowb,rowe,col,colb,cole,page,lwsize,    /* globel varibles*/
  40.              number_of_windows=0,number_max,wcolor,num_col,
  41.              frow,fcol,fpage,fnum_col,frowb,fcolb,frowe,
  42.              fcole,fcolor,scanstart,scanstop,scanstr,scanstp;
  43.  
  44. struct window_data far *first, far *last, far *present;    /* pionters to windo struct*/
  45.  
  46.  
  47. int fast;                                                  /* mono and screen write speed*/
  48.  
  49. output(int far *dest,int sour,int times);
  50. foutput(int far *dest,int sour,int times);
  51. screen(int far * dest,int far *sour,int times);
  52. fscreen(int far * dest,int far *sour,int times);
  53. screen_in(int far * dest,int far *sour,int times);
  54. screen_out(int far *dest,int far *sour,int times);
  55.  
  56. /*****************************************************************************/
  57. /* moniter() is to check for the type of moniter controller you have by      */
  58. /* checking the mode you are in you only use this function once. It will set */
  59. /* things up to use window. the screen write mode will be passed back -1=    */
  60. /* fast screen write 0= slow write so there will be no snow this can be      */
  61. /* changed with set_snow().                                                  */
  62. /* moniter();                                                                */
  63. /*****************************************************************************/
  64.  
  65.  monitor()
  66. {
  67.    reg.h.ah = 0x0F;                                        /* get mode */
  68.    int86(0x10,®,®);
  69.    num_col=reg.h.ah & 0xff;                                /* set number of col */
  70.    page=reg.h.bh;                                          /* set page */
  71.    rowb=0;colb=0;
  72.    rowe=25,cole=num_col;
  73.    number_of_windows=0;
  74.    if (reg.h.al == 7 )
  75.          { screenbase =(int far *) MONO; fast=TRUE;return(fast);}
  76.    else
  77.          { screenbase =(int far *) COLORM; fast=FALSE;return(fast);}
  78. }
  79.  
  80. /*****************************************************************************/
  81. /* this function is to pick wich function is used when writing to the screen */
  82. /* if your card displays snow set_snow(-1);                                  */
  83. /*****************************************************************************/
  84.  
  85. void set_snow(int m)
  86. {
  87.   fast=m;
  88.  
  89.  }
  90.  
  91.  
  92.  
  93. void cursor(int s,int e)
  94. {
  95.  reg.h.ah = 1;                                              /* set cursor size */
  96.  reg.h.ch = s;                                              /* starting line */
  97.  reg.h.cl = e;                                              /* ending line */
  98.  int86(0x10,®,®);
  99.  }
  100.  
  101. /*****************************************************************************/
  102. /* to set the cursor off cursoroff() will set the start line at 32 and       */
  103. /* the ending line at 0.                                                     */
  104. /*****************************************************************************/
  105. void cursoroff()
  106. {
  107.  reg.h.ah=3;
  108.  reg.h.bh=0;
  109.  int86(0x10,®,®);
  110.  if(reg.h.ch!=32)                                          /* if not off save*/
  111.  {
  112.   scanstart=reg.h.ch;                                      /* cursor start and*/
  113.   scanstop=reg.h.cl;                                       /* end*/
  114.   }
  115.  reg.h.ah = 1;                                             /* set cursor size */
  116.  reg.h.ch = 32;                                            /* starting line */
  117.  reg.h.cl = 0;                                             /* ending line */
  118.  int86(0x10,®,®);
  119.  }/* end of cursor off*/
  120.  
  121. /*****************************************************************************/
  122. /* to set the cursor on cursoroff() will set the start line with scanstart   */
  123. /* and the ending line with scanstop.                                        */
  124. /*****************************************************************************/
  125. void cursoron()
  126. {
  127.  reg.h.ah = 1;                                              /* set cursor size */
  128.  reg.h.ch = scanstart;                                      /* starting line */
  129.  reg.h.cl = scanstop;                                       /* ending line */
  130.  int86(0x10,®,®);
  131.  }/*end of cursor on*/
  132.  
  133. /*****************************************************************************/
  134. /* used by window to set the cursor off cursoroff() will set the start line  */
  135. /* at 32 and the ending line at 0.                                           */
  136. /*****************************************************************************/
  137.  void curoff()
  138. {
  139.  reg.h.ah=3;
  140.  reg.h.bh=0;
  141.  int86(0x10,®,®);
  142.  scanstr=reg.h.ch;
  143.  scanstp=reg.h.cl;
  144.  reg.h.ah = 1;                                              /* set cursor size */
  145.  reg.h.ch = 32;                                             /* starting line */
  146.  reg.h.cl = 0;                                              /* ending line */
  147.  int86(0x10,®,®);
  148.  }/* end of cursor off*/
  149.  
  150. /*****************************************************************************/
  151. /* used by window to set the cursor on cursoroff() will set the start line   */
  152. /* with scanstr and the ending line with scanstp.                            */
  153. /*****************************************************************************/
  154. void curon()
  155. {
  156.  reg.h.ah = 1;                                              /* set cursor size */
  157.  reg.h.ch = scanstr;                                        /* starting line */
  158.  reg.h.cl = scanstp;                                        /* ending line */
  159.  int86(0x10,®,®);
  160.  }/*end of cursor on*/
  161.  
  162. /*****************************************************************************/
  163. /* use this function to set the cursor any where on the screen.              */
  164. /* set_cur(0,0); puts the cursor in the left hand upper corner               */
  165. /*****************************************************************************/
  166.  
  167. void set_cur(unsigned char row,unsigned char col)
  168. {
  169. reg.h.ah = 2;                                              /* set cursor position */
  170. reg.h.bh = page;                                           /* page */
  171. reg.h.dh = row;
  172. reg.h.dl = col;
  173. int86(0x10,®,®);
  174. }
  175.  
  176. /*****************************************************************************/
  177. /* wgoto() is used to set the cursor with in the window                      */
  178. /* wgoto(0,0) puts the cursor in the upper left hand corner                  */
  179. /* of the window.                                                            */
  180. /*****************************************************************************/
  181.  
  182. void wgoto(unsigned char row,unsigned char col)
  183. {
  184. row+=rowb;if(row<rowb)row=rowb;                            /* offset into window*/
  185. col+=colb;if(col>cole)col=cole;
  186. reg.h.ah = 2;                                              /* set cursor position */
  187. reg.h.bh = page;                                           /* page */
  188. reg.h.dh = row;
  189. reg.h.dl = col;
  190. int86(0x10,®,®);
  191. }
  192.  
  193. /*****************************************************************************/
  194. /* after monitor is run you can clear any screen of window                   */
  195. /* clrscr();                                                                 */
  196. /*****************************************************************************/
  197.  
  198. void clrscr()
  199. {
  200.  int x,y,c;
  201.  int far * address;
  202.  for(x=rowb; x<=rowe; x++)
  203.     {
  204.      address = screenbase + ((x * num_col) + colb);
  205.      for(y=colb;y<=cole;y++)
  206.         {
  207.          c=((wcolor<<8)|0x20);
  208.          if(fast==TRUE) {foutput(address,c,1);}
  209.          else output(address,c,1);
  210.          *address++;
  211.         }
  212.     }
  213.     row=rowb;col=colb;
  214.     set_cur(row,col);
  215. }
  216.  
  217.  
  218. /*****************************************************************************/
  219. /* used by wprintf()                                                          */
  220. /*****************************************************************************/
  221. void scroll()
  222. {
  223.   
  224.   unsigned int x,y;
  225.   int c;
  226.   int far * address;
  227.   int far * address_old;
  228.   curoff();
  229.   for(row=rowb;row<rowe;row++)
  230.     {
  231.      address = screenbase + ((row * num_col) + colb);
  232.      address_old = screenbase + (((row+1) * num_col) + colb);
  233.      for(y=colb;y<=cole;y++)
  234.        {
  235.          if(fast==TRUE) {fscreen(address,address_old,1);}
  236.          else screen(address,address_old,1);
  237.          *address++;*address_old++;
  238.        }
  239.     }
  240.    address = screenbase + ((rowe * num_col) + colb);
  241.    for(x=colb;x<=cole;x++)
  242.       {
  243.        c=((wcolor<<8)|0x20);
  244.        if(fast==TRUE) {foutput(address,c,1);}
  245.        else output(address,c,1);
  246.        *address++;
  247.       }
  248.    row=rowe;
  249.    col=colb;
  250.    curon();
  251. }
  252.  
  253.  
  254.  
  255. /*****************************************************************************/
  256. /* used to return the number of windows that have bin made.                  */
  257. /*****************************************************************************/
  258.  
  259. num_of_w()
  260.   {
  261.    return(number_of_windows);
  262.    }
  263.  
  264. /*****************************************************************************/
  265. /* used to return the window that you are in                                 */
  266. /*****************************************************************************/
  267. int presentw()
  268.   {
  269.    return(present->wnumber);
  270.    }
  271.  
  272. /*****************************************************************************/
  273. /*  Function set_color is to set the color used by wprintf()                  */
  274. /*  Include in your progrom #include <screen.h> this will allow              */
  275. /*  you to write out the colors use B for background BWHITE all              */
  276. /*  constants are upper case  set_color(BWHITE|BLACK) will set               */
  277. /*  the color to white background and black letters.                         */
  278. /*  set_color(0x70);                                                         */
  279. /*****************************************************************************/
  280. void set_color(unsigned short color)
  281. {
  282.   wcolor=color;
  283.  }
  284.  
  285. /*****************************************************************************/
  286. /* save_window() is used by window to move the screen data to a save area    */
  287. /* it also chains this area to the window chain so you can move from window  */
  288. /* to window. The save area first starts with the window struct and then the */
  289. /* old screen data. The window save area has far pointers that are used to   */
  290. /* access and save area. The number of windows is saved in number_of_windows */
  291. /*****************************************************************************/
  292.  
  293. void  save_window(int bd, int bdcolor, unsigned int size)
  294. {
  295.   int far * windstore;                                     /* pointer to save area*/
  296.   int far * temp;                                          /* pointer to save area*/
  297.   unsigned int size1;
  298.   unsigned int x,y;
  299.   unsigned short i,found;
  300.   struct window_data far *windata,far * windtemp,far * windtemp2; /* pointers to window struct*/
  301.   windata=farmalloc(((long)size+sizeof(struct window_data)));  /* get scace from memory*/
  302.   windstore=(void far *)(windata+1);                           /* windstore now points to end of struct +1*/
  303.   if(number_of_windows==0)
  304.     {/*1*/                                                 /* if first window save screen data*/
  305.       reg.h.ah = 3;                                       /* get cursor position */
  306.       reg.h.bh = page;                                    /* page */
  307.       int86(0x10,®,®);
  308.       frow = reg.h.dh;                                    /* save cursor row*/
  309.       fcol = reg.h.dl;                                    /* and curcor collum*/
  310.       reg.h.ah = 8;                                       /* get attribute at cursor position */
  311.       reg.h.bh = page;                                    /* page */
  312.       int86(0x10,®,®);
  313.       fcolor = reg.h.ah;                                  /* save color*/
  314.       fnum_col=num_col;                                    /* save number of collums on screen*/
  315.       fpage=page;                                          /* save page*/
  316.       frowb=0;fcolb=0;
  317.       frowe=25;fcole=num_col;
  318.       fscreenbase=screenbase;                              /* screen base address*/
  319.       windata->last=NULL;last=NULL;                        /* NULL ends of chain*/
  320.      windata->next=NULL;
  321.     }/*end of if1*/
  322.  
  323.   windata->bd=bd;windata->bdcolor=bdcolor;                 /* save data on window*/
  324.   windata->size=size;windata->wcolor=wcolor;               /* size color*/
  325.   windata->wrowb=rowb;windata->wcolb=colb;                 /* starting row-col*/
  326.   windata->wrowe=rowe;windata->wcole=cole;                 /* ending row-col*/
  327.   windata->wpage=page;windata->wmode=getmode();            /* page  screen mode*/
  328.   windata->wnum_col=num_col;                               /* number of col*/
  329.  
  330.   windata->screenbase=(int far *)screenbase;               /* screen base address*/
  331.  
  332.  
  333.                                                            /* save screen */
  334.   windata->addressave=windstore;
  335.   for(row=rowb;row<=rowe;row++)                            /* first row to last*/
  336.      {/*1*/
  337.       temp= screenbase+((row * num_col) + colb);           /* address of first col on row*/
  338.       if(fast==TRUE) {fscreen(windstore,temp,(cole-colb)+1);} /* no snow*/
  339.       else screen_out(windstore,temp,(cole-colb)+1);          /* snow */
  340.       windstore+=(cole-colb)+1;                            /* next line*/
  341.       }/*end of for1*/
  342.   number_of_windows++;                                     /* keep track of windows*/
  343.  
  344.   if(number_of_windows>1)                                  /* add struct to chain*/
  345.   {/*2*/
  346.     windtemp=last;                                         /* start from end*/
  347.     while(windtemp->last!=NULL)                            /* find first window*/
  348.        { windtemp=windtemp->last;}
  349.     i=1;
  350.     if(i<windtemp->wnumber)                                /* is spot first link*/
  351.       {/*3*/
  352.         windata->wnumber=i;windata->next=windtemp;         /* chain new link to old first link*/
  353.         windata->last=windtemp->last;                      /* NULL end of chain*/
  354.         windtemp->last=windata;                            /* chain old first link to new*/
  355.       }/*end of if3*/
  356.     else                                                   /* if now first link*/
  357.       {/*1*/
  358.         found=FALSE;
  359.         while(found==FALSE)                                /* get spot for link*/
  360.            {/*1*/
  361.             while(i<=windtemp->wnumber)i++;                /* see if link will fit in chain*/
  362.             if(i>windtemp->wnumber && ((windtemp->next==NULL) || i<windtemp->next->wnumber))
  363.               { /*4*/                                      /* link fit */
  364.                windata->wnumber=i;windata->next=windtemp->next; /* add link to chain*/
  365.                windata->last=windtemp;
  366.                if(windtemp->next!=NULL)                    /* if not end*/
  367.                  {/*5*/                                    /* fits between links*/
  368.                    windtemp2=windtemp->next;
  369.                    windtemp2->last=windata;
  370.                   }/*end of if5*/
  371.                windtemp->next=windata;
  372.                found=TRUE;                                 /* found spot*/
  373.               }/*end of if4*/
  374.             else                                           /* fits at end of chain*/
  375.               {/*2*/
  376.                 windtemp=windtemp->next;                   /* no fit get next link in chain*/
  377.                }/*end of else2*/
  378.  
  379.            }/*end of while1*/
  380.       }/*end of else1*/
  381.     }/*end of if2*/
  382.     else windata->wnumber=1;                                /* first window*/
  383.   if(windata->next==NULL)last=windata;                      /* if new window is last keep track*/
  384.   present=windata;                                          /* set present to window now in*/
  385. }/*end of save*/
  386.  
  387. /*****************************************************************************/
  388. /*  Function window() is to create the window all that is needed             */
  389. /*  is to set up the upper left corner, the bottom right corner,             */
  390. /*  the border color (background-foreground), you should allready            */
  391. /*  have used set_color(background|foreground) for the window                */
  392. /*  itself. If a window can not be created window() will pass                */
  393. /*  back 0, if the window was created the window number will be              */
  394. /*  passed back.                                                             */
  395. /*  If the window is to small it will not be allowed to fave a               */
  396. /*  border, the window with or without a border must be at least             */
  397. /*  one character space in size. All window are chained together             */
  398. /*  by pointers and you can move from one window to another.                 */
  399. /*  window(0,0,24,79,1,0x70);                                                */
  400. /*****************************************************************************/
  401.  
  402. int window(char xb,char yb,char xe,char ye,char bdr,unsigned char bdcolor)
  403. {
  404.     /*
  405.       0;         { No border           }     For a border type pass one of
  406.       1;         { Single border       }     the 13 different border numbers
  407.       2;         { Double border       }
  408.       3;         { Mixed border        }
  409.       4;         { Mixed2 border       }
  410.       5;         { Solid border        }
  411.       6;         { Light hatch border  }
  412.       7;         { Medium hatch border }
  413.       8;         { Dense hatch border  }
  414.       9;         { Mixed3 border       }
  415.      10;         { Mixed4 border       }
  416.      11;         { Mixed5 border       }
  417.      12;         { Mixed6 border       }
  418.      13;         { Mixed7 border       }
  419.     */
  420.  
  421.  int out;
  422.  unsigned int size;                                       /*size of window*/
  423.  int far *address;                                        /*address of window on screen*/
  424.  char far *tempdata,char_address;
  425.  int t,x,y,c,border;
  426.  unsigned char border_char[13][8]={
  427.           {'┌','┐','└','┘','─','─','│','│'},              /* single */
  428.           {'╔','╗','╚','╝','═','═','║','║'},              /* double */
  429.           {'╒','╕','╘','╛','═','═','│','│'},              /* mixed  */
  430.           {'╓','╖','╙','╜','─','─','║','║'},              /* mixed2 */
  431.           {'█','█','█','█','█','█','▌','▐'},              /* solid  */
  432.           {'░','░','░','░','░','░','░','░'},              /* lhatch */
  433.           {'▒','▒','▒','▒','▒','▒','▒','▒'},              /* mhatch */
  434.           {'▓','▓','▓','▓','▓','▓','▓','▓'},              /* dhatch */
  435.           {0xdf,0xdf,0xdc,0xdc,0xdf,0xdc,0xdd,0xde},      /* mixed3 */
  436.           {0xda,0xbf,0xc0,0xd9,0xdf,0xdc,0xdd,0xde},      /* mixed4 */
  437.           {0xda,0xbf,0xc0,0xd9,0xdb,0xdb,0xdb,0xdb},      /* mixed5 */
  438.           {0xc9,0xbb,0xc8,0xbc,0xdf,0xdc,0xdd,0xde},      /* mixed6 */
  439.           {0xc9,0xbb,0xc8,0xbc,0xdb,0xdb,0xdd,0xde}       /* mixed7 */
  440.           };
  441.  curoff();
  442.                                                            /* if(ye>=num_col-1){ye=num_col-1;}               /* check to see if the */
  443.  if (xb>xe) {t=xb;xb=xe;xe=t;}                             /* window begining is  */
  444.  if (yb>ye) {t=yb;yb=ye;ye=t;}                             /* not after end       */
  445.   rowb=xb;
  446.   colb=yb;
  447.   rowe=xe;
  448.   cole=ye;
  449.   border=bdr;
  450.   if(rowb+2>rowe){border=0;}
  451.   if(colb+2>cole){border=0;}
  452.  
  453.   row=rowb;col=colb;
  454.   size=(rowe-rowb+1)*(cole-colb+1)*2;                      /* check memory for room */
  455.   if(farcoreleft() < 1000+size+sizeof(struct window_data))
  456.     {curon();return(FALSE);}                            /* pass 0 if no room     */
  457.   else                                                     /* make window*/
  458.   {/*1*/
  459.   save_window(border,bdcolor,size);                        /* save old screen and window data */
  460.   clrscr();                                                /* clear the new window using the color from set_color*/
  461.   if(border>=1)                                            /* if window has a border*/
  462.   {/*end of else 1*/
  463.   --border;
  464.   for(row=rowb;row<=rowe;++row)                            /* draw border */
  465.      {/*1*/
  466.        if(rowb<row&&rowe>row)                              /* draw mid section of window*/
  467.          {/*1*/
  468.            for (y=0, col=colb;y<=1;y++,col=cole)           /* to end of line*/
  469.                {/*2*/
  470.                 if(col==colb)                              /* if first collum */
  471.                   {/*3*/
  472.                     c=(int)border_char[border][6];         /* c=left side */
  473.                    }/*end of if3*/
  474.                   else                                     /* display right side */
  475.                     {/*2*/
  476.                        c=(int)border_char[border][7];      /* c=right side */
  477.                      }/*end of else2*/
  478.                    address = screenbase + ((row * num_col) + col);
  479.                    c=((bdcolor<<8)|c);                      /* add color to c and write to screen*/
  480.                    if(fast==TRUE) {foutput(address,c,1);}   /* if no snow*/
  481.                    else output(address,c,1);                /* if snow*/
  482.                  }/*end of for2*/
  483.               continue;                                     /* do next row*/
  484.             }/*end of if2*/
  485.  
  486.             if(row==rowb)                                   /* draw top line*/
  487.               {/*4*/
  488.                for (col=colb;col<=cole;++col)               /* to end of line*/
  489.                  {/*3*/
  490.                   if(col==colb)                             /* if left corner*/
  491.                     { /*5*/
  492.                       c=(int)border_char[border][0];        /* c=left corner*/
  493.                      }/*end of if5*/
  494.                    else                                     /* mid section*/
  495.                       {/*3*/
  496.                         c=(int)border_char[border][4];      /* c=mid section*/
  497.                        }/*end of else3*/
  498.                    if(col==cole)                            /* if right corner*/
  499.                      {/*6*/
  500.                        c=(int)border_char[border][1];       /* c=right corner*/
  501.                       }/*end of if6*/
  502.                     address = screenbase + ((row * num_col) + col);  /* address where to put character*/
  503.                     c=((bdcolor<<8)|c);                     /* add color to c and write to screen*/
  504.                     if(fast==TRUE) {foutput(address,c,1);}  /* if no snow use this*/
  505.                     else output(address,c,1);               /* moniter has snow */
  506.                   }/*end of for3*/
  507.                   continue;                                 /* draw next row*/
  508.               }/*end of if4*/
  509.  
  510.              if(row==rowe)                                  /* draw bottom line*/
  511.               {/*7*/
  512.                for (col=colb;col<=cole;++col)               /* to end of line*/
  513.                   {/*4*/
  514.                    if(col==colb)                            /* if left corner*/
  515.                      {/*8*/
  516.                       c=(int)border_char[border][2];        /* c= bottom left corner*/
  517.                       }/*end of if8*/
  518.                     else                                    /* if mid section*/
  519.                       {/*4*/
  520.                        c=(int)border_char[border][5];       /* c=mid section*/
  521.                        }/*end of else4*/
  522.                     if(col==cole)                           /* if right side*/
  523.                       {/*9*/
  524.                        c=(int)border_char[border][3];       /* c=bottom right corner*/
  525.                       }/*end of if9*/
  526.                       address = screenbase + ((row * num_col) + col);  /* address where to put c*/
  527.                       c=((bdcolor<<8)|c);                   /* add color to c and write to screen*/
  528.                       if(fast==TRUE) {foutput(address,c,1);}/* no snow*/
  529.                       else output(address,c,1);             /* snow*/
  530.                   }/*end of for4*/
  531.               }/*end of if7*/
  532.            }/*end of for1*/
  533.         ++border;                                           /* restore border*/
  534.      }/*end of if1*/
  535.  
  536.   if(border>=1)                                             /* if window has a*/
  537.   { /*10*/                                                  /* border shrink*/
  538.     ++rowb;                                                 /* window to fit*/
  539.     ++colb;
  540.     --rowe;
  541.     --cole;
  542.   }/*end of if10*/                                          /* put cursor in */
  543.   row=rowb;col=colb;                                        /* right hand top */
  544.   set_cur(rowb,colb);                                       /* corner*/
  545.   present->wcurr = row;
  546.   present->wcurc = col;
  547.   }/*end of else1*/
  548.  curon();
  549.  return(present->wnumber);
  550. }/*end of window()*/
  551.  
  552.  
  553.  
  554.  
  555. /*****************************************************************************/
  556. /* delete_window() will delete any window that you are not presently in. The */
  557. /* only time you can delete a window that you are is when you are at the end */
  558. /* of the chain and pass 0 to delete_window(0); . This will delete the end   */
  559. /* window (link) and put you in the new end window (link).                   */
  560. /* delete_window is not smart yet so, if a window is on top of the window you*/
  561. /* delete the old data will be placed over the top window, so you must keep  */
  562. /* track of the windows your self.                                           */
  563. /* if window is not found 0 will be pass back and if window was deleted a -1 */
  564. /* will be returned.                                                         */
  565. /* You MUST use option 0 to delete the last window.                          */
  566. /* delete_window(5);                                                         */
  567. /*****************************************************************************/
  568.  
  569. int delete_window(unsigned short wnum)
  570. {
  571.  int far *windstore;                                       /* pionters to save area*/
  572.  int far *temp;
  573.  unsigned int size;
  574.  int x,y;
  575.  unsigned short srowb,scolb,srowe,scole,
  576.           snum_col,store_size;
  577.  struct window_data far *windata;                          /* pionters to the window struct*/
  578.  curoff();
  579.  if(number_of_windows>0)                                   /* if 0 no windows*/
  580.   {/*1*/
  581.   present->wcurr=row;                                      /* save curser of present window*/
  582.   present->wcurc=col;
  583.   if(wnum>0)                                               /* if not 0 find window to*/
  584.   {/*2*/                                                   /* delete*/
  585.    windata=present;                                        /* if not same as present*/
  586.    if(windata->wnumber!=wnum)                              /* find*/
  587.    {/*3*/
  588.      if(windata->wnumber>wnum)                             /* go back*/
  589.         {/*4*/
  590.         while(windata->last!=NULL && windata->wnumber!=wnum)  /* and find window or end of chain*/
  591.              {windata=windata->last;}
  592.         if(windata->wnumber!=wnum)return(FALSE);              /* was window found or NULL if NULL return 0*/
  593.         }/*end of if4*/
  594.      else                                                  /* check to end*/
  595.         {/*1*/                                             /*go fowards*/
  596.         while(windata->next!=NULL && windata->wnumber!=wnum)
  597.              {windata=windata->next;}
  598.         if(windata->wnumber!=wnum)return(FALSE);           /* if not found return -1*/
  599.         }/*end of else1*/
  600.     }/*end of if3*/
  601.     else {curon();return(FALSE);}                       /* if same window, can not delete same window*/
  602.   }/*end of if2*/                                          /* that you are on with this option*/
  603.   else if(wnum==0)windata=last;                            /* used option 0 delete last window*/
  604.   if(wnum>=0)                                              /* delete window if a positive number*/
  605.    {/*5*/
  606.      if(last==windata)last=windata->last;                  /*set last window if new*/
  607.      windstore=windata->addressave;                        /*get address of saved screen*/
  608.      srowb=windata->wrowb;scolb=windata->wcolb;            /*restore window data*/
  609.      srowe=windata->wrowe;scole=windata->wcole;
  610.      snum_col=windata->wnum_col;
  611.      store_size=((scole-scolb)+1);
  612.      for(row=srowb;row<=srowe;row++)                       /* restore screen */
  613.        { /*1*/
  614.          temp=screenbase+((row * snum_col) + scolb);       /* address of screen pos*/
  615.          if(fast==TRUE) {fscreen(temp,windstore,store_size);}/* no snow*/
  616.          else screen_in(temp,windstore,store_size);          /* snow*/
  617.          windstore+=store_size;                            /* next line*/
  618.        }/*end of for1*/
  619.  
  620.     }/*end of if5*/
  621.                                                            /* if last window was deleted*/
  622.    if(wnum==0 && last!=NULL)                               /* restore if option 0*/
  623.      {/*6*/                                                /* and window to restore*/
  624.         present=last   ;                                   /* present window is last window*/
  625.         wcolor=present->wcolor;                            /* get setup of*/
  626.         rowb=present->wrowb;colb=present->wcolb;           /* new present */
  627.         rowe=present->wrowe;cole=present->wcole;           /* window*/
  628.         page=present->wpage;num_col=present->wnum_col;
  629.         screenbase=present->screenbase;
  630.         row=present->wcurr; col=present->wcurc;
  631.         set_cur(row,col);
  632.         if(present->bd>=1)                                 /* if border shrink*/
  633.           {/*7*/                                           /* window*/
  634.            ++rowb;
  635.            ++colb;
  636.            --rowe;
  637.            --cole;
  638.           }/*end of if7*/
  639.      }/*end of if6*/
  640.  
  641.  
  642.  
  643.    if(windata->next!=NULL && windata->last!=NULL)          /* relink chain*/
  644.      {/*8*/
  645.        windata->last->next=windata->next;
  646.        windata->next->last=windata->last;
  647.      }/*end of if8*/
  648.    else
  649.      {/*3*/
  650.        if(windata->last==NULL && windata->next!=NULL)      /* or NULL end*/
  651.          {windata->next->last=NULL;}
  652.        if(windata->next==NULL && windata->last!=NULL)
  653.          {windata->last->next=NULL;}
  654.       }/*end of else3*/
  655.  
  656.    farfree(windata);                                       /* free momory*/
  657.    number_of_windows--;                                    /* dec number of windows*/
  658.    if(number_of_windows==0)                                /* if last windo restore*/
  659.      {/*9*/                                                /* screen data*/
  660.        num_col=fnum_col;
  661.        page=fpage;
  662.        row=frow;col=fcol;
  663.        rowb=frowb;colb=fcolb;
  664.        rowe=frowe;cole=fcole;
  665.        screenbase=fscreenbase;
  666.        wcolor=fcolor;
  667.        set_cur(row,col);
  668.       }/*end of if9*/
  669.     
  670.   }/*end of if1*/
  671.   curon();
  672.   return(TRUE);
  673. }/*end of main*/
  674.  
  675.  
  676.  
  677. /*****************************************************************************/
  678. /* To change to another window all you have to do is pass the window number  */
  679. /* assigned to it when make. If you can move to the window a -1 will be      */
  680. /* passed back else a 0 if not.                                              */
  681. /* change_window(5);                                                         */
  682. /*****************************************************************************/
  683.  
  684. change_window(unsigned short wnum)
  685. {
  686. unsigned short num;
  687. struct window_data far *windo,far *windata;
  688. windata=present;
  689. reg.h.ah = 3;                                              /* get cursor position */
  690. reg.h.bh = page;                                           /* page */
  691. int86(0x10,®,®);
  692. windata->wcurr = reg.h.dh;                                 /* update this window struct*/
  693. windata->wcurc = reg.h.dl;                                 /* befor moving*/
  694. if(windata->wnumber!=wnum)                                 /* find new window*/
  695.   {
  696.     if(windata->wnumber>wnum)                              /* is window you are at after*/
  697.        {                                                   /* window you need*/
  698.        while(windata->last!=NULL&&windata->wnumber!=wnum)
  699.             {windata=windata->last;}                       /* move back*/
  700.        if(windata->wnumber!=wnum)return(FALSE);            /* if not found return false*/
  701.        }
  702.     else
  703.        {                                                   /* window is befor window you need*/
  704.        while(windata->next!=NULL&&windata->wnumber!=wnum)
  705.             {windata=windata->next;}                       /* get next window*/
  706.        if(windata->wnumber!=wnum)return(FALSE);            /* not found*/
  707.        }
  708.     present=windata;                                       /* found window*/
  709.     row=windata->wcurr; col=windata->wcurc;                /* get cursor data*/
  710.     set_cur(row,col);                                      /* set cursor*/
  711.     wcolor=windata->wcolor;
  712.     rowb=windata->wrowb;colb=windata->wcolb;               /* restore window data*/
  713.     rowe=windata->wrowe;cole=windata->wcole;
  714.     page=windata->wpage;num_col=windata->wnum_col;
  715.     screenbase=windata->screenbase;
  716.     if(windata->bd>=1)                                     /* if a border make window fit*/
  717.       {
  718.        ++rowb;
  719.        ++colb;
  720.        --rowe;
  721.        --cole;
  722.        }
  723.   }
  724.     return(TRUE);
  725. }
  726.  
  727. /*****************************************************************************/
  728. /* To write to a window or screen  you must run moniter() once to set up for */
  729. /* wprintf() to work. you set the color with set_color() and can put the      */
  730. /* cursor where you want by wset_cur() or set_cur(). wprintf() will check for */
  731. /* cr ,lf and 0 to give you a crlf or find the end of a string. If you want  */
  732. /* to a formated string use sprintf() first then wprintf().                   */
  733. /* wprintf(" This is a test \n");                                             */
  734. /* or                                                                        */
  735. /* sprint(ch," %d %f ",dec,flt);                                             */
  736. /* wprintf(ch);                                                               */
  737. /*****************************************************************************/
  738.  
  739. void wprintf(char *string, ...)
  740. {
  741.   int far *address;
  742.   int data;
  743.   int j,x,string_length,
  744.        line_feed=FALSE;
  745.   char strbuff[140];
  746.   va_list ap;
  747.   va_start( ap, string);
  748.   vsprintf(strbuff, string, ap);
  749.   va_end( ap);
  750.   string = strbuff;
  751.   reg.h.ah = 3;                                            /* get cursor position */
  752.   reg.h.bh = page;                                         /* page */
  753.   int86(0x10,®,®);
  754.   row = reg.h.dh;                                          /* so we know where to print*/
  755.   col = reg.h.dl;                                          /* string on screen*/
  756.   curoff();
  757.   address = screenbase + ((row * num_col) + col);          /* address of screen*/
  758.   string_length = strlen(string);                          /* string length*/
  759.   for (j = string_length; j >0;--j)                        /* output until end of string*/
  760.     {
  761.      if(*string == 0x0a||*string == 0x0d)                  /* check for CR or LF*/
  762.        {line_feed=TRUE;}
  763.      else
  764.        {
  765.          if ((col == (cole+1)) && (row == rowe))           /* if end of window*/
  766.            {                                               /* scroll*/
  767.              scroll();
  768.             } /*end of if*/
  769.           line_feed=FALSE;
  770.           address = screenbase + ((row * num_col) + col);
  771.           data=(wcolor<<8)|*string++;
  772.           if(fast==TRUE) {foutput(address,data,1);}        /* put data in screen*/
  773.           else output(address,data,1);                     /* memory*/
  774.           *address++;
  775.          } /*end of else*/
  776.         if ((col == cole)&&(row != rowe))                  /* if end of line */
  777.            {                                               /* new line*/
  778.              ++row;col = colb;
  779.             }/*end of if*/
  780.         else col++;
  781.  
  782.      if (line_feed )
  783.         {
  784.           if(row != rowe)                                  /* check for end of window*/
  785.             {
  786.               col = colb;
  787.               row++;
  788.               *string++;
  789.               line_feed=FALSE;
  790.              }
  791.            else                                            /* if end scroll*/
  792.              {
  793.                scroll();
  794.                *string++;
  795.                line_feed=FALSE;
  796.               } /*e f else*/
  797.          }/*end of if*/
  798.      }/*end of for*/                                       /* if line feed*/
  799.      curon();
  800.      set_cur(row,col);                                     /* place cursor*/
  801. }
  802.  
  803. /*****************************************************************************/
  804. /* To title a window all you need to do is pass a string that you want to be */
  805. /* put in the midle of the top border and the color you want the title.      */
  806. /* titlef(" HELP WINDOW ");                                                  */
  807. /*****************************************************************************/
  808.  
  809. void titlef(char *string,unsigned short color)
  810. {
  811.  int far *address;
  812.  unsigned short rowt,colt,colort,rb,cb,ce;
  813.  rowt=row;colt=col;                                        /* save cursor*/
  814.  colort=wcolor;                                            /* and color*/
  815.  wcolor=color;
  816.  rb=present->wrowb,cb=present->wcolb;ce=present->wcole;    /* find middle of windo*/
  817.  set_cur(rb,cb+(((ce-cb)-strlen(string))/2)+1);            /* place string*/
  818.  wprintf(string);
  819.  wcolor=colort;                                            /* restore cursor*/
  820.  row=rowt;col=colt;                                        /* and color*/
  821.  set_cur(row,col);                                         /* put cursor back*/
  822.  }
  823.  
  824. /*****************************************************************************/
  825. /* readf() will read from the the console to the end of the window.          */
  826. /* you must declare a buffer[] string and must be at least 1 bigger then the */
  827. /* window. window() will return the length of the string read and 0 term.    */
  828. /* char buffer[11];                                                          */
  829. /* readf(buffer);                                                            */
  830. /*****************************************************************************/
  831. readf(unsigned char *buff)
  832. {
  833.   unsigned short colw,x,size,length;
  834.   int s;
  835.  reg.h.ah = 3;                                             /* get cursor position */
  836.  reg.h.bh = page;                                          /* page */
  837.  int86(0x10,®,®);
  838.  col = reg.h.dl;
  839.  row = reg.h.dh;
  840.  buff[0]=(unsigned int)((cole+1)-col);                     /* set size of buffer in [0]*/
  841.  sreg.ds=_DS;                                              /* seg of buffer*/
  842.  reg.x.dx=(unsigned)buff;                                  /* offset in dx*/
  843.  reg.h.ah=10;                                              /* read kb*/
  844.  int86x(0x21,®,®,&sreg);
  845.  
  846.  length=buff[1];                                           /* length read in*/
  847.  for(x=0;x<length;buff[x]=buff[x+2],x++);buff[x+2]=0;      /* shift left by 2*/
  848.  buff[length]='\0';                                        /* NULL end of buffer*/
  849.  set_cur(row,(col+length));                                /* set cursor*/
  850.  return(length);
  851.  }
  852.  
  853. /****************************************************************************/
  854. /* freadf() is the same as readf() only you tell it the size of input string*/
  855. /* freadf(buffer,10);                                                       */
  856. /****************************************************************************/
  857.  
  858. freadf(unsigned char *buff,int s)
  859. {
  860.   unsigned short colw,x,size,length;
  861.  reg.h.ah = 3;                                             /* get cursor position */
  862.  reg.h.bh = page;                                          /* page */
  863.  int86(0x10,®,®);
  864.  col = reg.h.dl;
  865.  row = reg.h.dh;
  866.  if(s==0)                                                  /* if not formatted */
  867.  buff[0]=(unsigned int)((cole+1)-col);                     /* set size of buffer in [0]*/
  868.  else                                                      /* formatted read*/
  869.     {
  870.       if(s<=((cole+1)-col)) buff[0]=s+1;
  871.       else buff[0]=(unsigned int)((cole+1)-col);
  872.      }
  873.  sreg.ds=_DS;                                              /* seg of buffer*/
  874.  reg.x.dx=(unsigned)buff;                                  /* offset in dx*/
  875.  reg.h.ah=10;                                              /* read kb*/
  876.  int86x(0x21,®,®,&sreg);
  877.  
  878.  length=buff[1];                                           /* length read in*/
  879.  for(x=0;x<length;buff[x]=buff[x+2],x++);buff[x+2]=0;      /* shift left by 2*/
  880.  buff[length]='\0';                                        /* NULL end of buffer*/
  881.  set_cur(row,(col+length));                                /* set cursor*/
  882.  return(length);
  883.  }
  884.  
  885.  
  886. /*****************************************************************************/
  887.  /*                          ega mode are                                    */
  888.  /*   mode display display pages colors resolution char_h/v char_size        */
  889.  /*     0   text    color   8     16   320x200      40x25      8x8           */
  890.  /*     1   text    enhance 8   16/64  320x200      40x25      8x14          */
  891.  /*     2    "      color   8     16   640x200      80x25      8x8           */
  892.  /*     3    "      enhance 8   16/64  640x350        "        8x14          */
  893.  /*   4/5  graph    c/e     1     4    320x200      40x25      8x8           */
  894.  /*     6  graph    c/e     1     2    640x200      80x25      8x14          */
  895.  /*     7   test    mono    8     4    720x350      80x25      9x14          */
  896.  /*    13  graph    c/e    2,4,8  16   320x200      40x25      8x8           */
  897.  /*    14    "       "     1,2,4  16   640x200      80x25      8x8           */
  898.  /*    15    "      mono    1,2   4    640x350      80x25      8x14          */
  899.  /*    16    "      enhance 1,2  16/64 640x350      80x25      8x14          */
  900.  /****************************************************************************/
  901.  
  902.  
  903.  
  904. setmode(int mode)                                          /* set mode as passed*/
  905. {
  906.  reg.h.al = mode;
  907.  reg.h.ah =0;
  908.  int86(0x10,®,®);
  909.  }
  910.  
  911.  
  912. int getmode()
  913. {
  914.  reg.h.al = 0;
  915.  reg.h.ah =0x0f;
  916.  int86(0x10,®,®);                                    /* pass back mode*/
  917.  return(reg.h.al);
  918.  }
  919.  
  920.  
  921. /****************************************************************************/
  922. /*  used by window                                                          */
  923. /****************************************************************************/
  924.  
  925. output(int far * dest,int sour,int times)
  926. {
  927. asm          LES DI,dest                                   /* ES:DI = DEST */
  928. asm          lea si,sour                                   /* SI = data ADDRESS*/
  929. asm          mov cx,[times]
  930. asm          CLD                                           /* Set direction to forward*/
  931. asm          MOV DX,03DAH                                  /* Point DX to status port*/
  932. nextchar:
  933. asm          lodsw
  934. asm          MOV BX,AX                                     /* Store video word in BX*/
  935. asm          MOV AH,09H                                    /* Move horizontal & vertical*/
  936.  
  937. waith:
  938. asm          IN AL,DX                                      /* Get 6845 status*/
  939. asm          test AL,1                                     /* Wait horizontal OFF*/
  940. asm          JNZ waith                                     /* retrace*/
  941.  
  942. asm          CLI                                           /* No interrupts now*/
  943. waitv:
  944. asm          IN AL,DX                                      /* Get 6845 status again*/
  945. asm          and AL,AH                                     /* Wait horizonal ON*/
  946. asm          JZ waitv                                      /* retrace*/
  947.  
  948. asm          MOV AX,BX                                     /* Move word back to AX...*/
  949. asm          STOSW                                         /* and then to screen*/
  950. asm          STI                                           /* Allow interrupts!*/
  951. asm          loop nextchar
  952. }/* end of output*/
  953.  
  954. /****************************************************************************/
  955. /*  used by window                                                          */
  956. /****************************************************************************/
  957.  
  958. foutput(int far * dest,int sour,int times)
  959. {
  960. asm          LES DI,dest                                   /* DS:SI will DEST*/
  961. asm          lea si,sour                                   /* SI = data ADDRESS*/
  962. asm          mov cx,[times]
  963. asm          CLD                                           /* Set direction to forward*/
  964. nextchar:
  965. asm          lodsw
  966. asm          STOSW                                         /* and then to screen*/
  967. asm          loop nextchar
  968. }/* end of output*/
  969.  
  970. /****************************************************************************/
  971. /*  used by window                                                          */
  972. /****************************************************************************/
  973.  
  974. screen_in(int far * dest,int far *sour,int times)
  975. {
  976. asm          push ds                                       /* SAVE DS*/
  977. asm          LES DI,dest                                   /* ES:DI WILL POINT TO DEST*/
  978. asm          lds si,sour                                   /* DS:SI WILL POINT TO SOURCE*/
  979. asm          mov cx,[times]
  980. asm          CLD                                           /* Set direction to forward*/
  981. asm          MOV DX,03DAH                                  /* Point DX to status port*/
  982. nextchar:
  983. asm          lodsw
  984. asm          MOV BX,AX                                     /* Store video word in BX*/
  985. asm          MOV AH,09H                                    /* Move horizontal & vertical*/
  986.  
  987. waith:
  988. asm          IN AL,DX                                      /* Get 6845 status*/
  989. asm          test AL,1                                     /* Wait horizontal OFF*/
  990. asm          JNZ waith                                     /* retrace*/
  991.  
  992. asm          CLI                                           /* No interrupts now*/
  993. waitv:
  994. asm          IN AL,DX                                      /* Get 6845 status again*/
  995. asm          and AL,AH                                     /* Wait horizonal ON*/
  996. asm          JZ waitv                                      /* retrace*/
  997.  
  998. asm          MOV AX,BX                                     /* Move word back to AX...*/
  999. asm          STOSW                                         /* and then to screen*/
  1000. asm          STI                                           /* Allow interrupts!*/
  1001. asm          loop nextchar
  1002. asm          pop ds                                        /* RESTORE DS*/
  1003. }/* end of output*/
  1004.  
  1005. /****************************************************************************/
  1006. /*  used by window                                                          */
  1007. /****************************************************************************/
  1008.  
  1009. screen_out(int far *dest,int far *sour,int times)
  1010. {
  1011. asm          push ds
  1012. asm          LES DI,dest                                   /* ES:DI will point to SOUCE*/
  1013. asm          lds si,sour                                   /* DS:SI WILL POINT TO DEST*/
  1014. asm          mov cx,[times]
  1015. asm          CLD                                           /* Set direction to forward*/
  1016. asm          MOV DX,03DAH                                  /* Point DX to status port*/
  1017. nextchar:
  1018.  
  1019. asm          MOV AH,09H                                    /* Move horizontal & vertical*/
  1020.  
  1021. waith:
  1022. asm          IN AL,DX                                      /* Get 6845 status*/
  1023. asm          test AL,1                                     /* Wait horizontal OFF*/
  1024. asm          JNZ waith                                     /* retrace*/
  1025.  
  1026. asm          CLI                                           /* No interrupts now*/
  1027. waitv:
  1028. asm          IN AL,DX                                      /* Get 6845 status again*/
  1029. asm          and AL,AH                                     /* Wait horizonal ON*/
  1030. asm          JZ waitv                                      /* retrace*/
  1031.  
  1032. asm          lodsw
  1033. asm          STOSW                                         /* and then to screen*/
  1034. asm          STI                                           /* Allow interrupts!*/
  1035. asm          loop nextchar
  1036. asm          pop  ds                                       /* RESTORE DS*/
  1037. }/* end of output*/
  1038.  
  1039. /****************************************************************************/
  1040. /*  used by window                                                          */
  1041. /****************************************************************************/
  1042.  
  1043. screen(int far * dest,int far *sour,int times)
  1044. {
  1045. asm          push ds                                       /* SAVE DS*/
  1046. asm          LES DI,dest                                   /* ES:DI will point to St[0]*/
  1047. asm          lds si,sour                                   /* DS:SI = SOUR*/
  1048. asm          mov cx,[times]
  1049. asm          CLD                                           /* Set direction to forward*/
  1050. asm          MOV DX,03DAH                                  /* Point DX to CGA status port*/
  1051. nextchar:
  1052. asm          MOV AH,09H                                    /* Move horizontal & vertical*/
  1053.  
  1054. waith2:
  1055. asm          IN AL,DX                                      /* Get 6845 status*/
  1056. asm          test AL,1                                     /* Wait horizontal OFF*/
  1057. asm          JNZ waith2                                    /* retrace*/
  1058.  
  1059. asm          CLI                                           /* No interrupts now*/
  1060. waitv2:
  1061. asm          IN AL,DX                                      /* Get 6845 status again*/
  1062. asm          and AL,AH                                     /* Wait horizonal ON*/
  1063. asm          JZ waitv2                                     /* retrace*/
  1064.  
  1065. asm          LODSW                                         /* and then to screen*/
  1066. asm          STI                                           /* Allow interrupts!*/
  1067.  
  1068. asm          MOV BX,AX                                     /* Store video word in BX*/
  1069. asm          MOV AH,09H                                    /* Move horizontal & vertical*/
  1070.  
  1071. waith:
  1072. asm          IN AL,DX                                      /* Get 6845 status*/
  1073. asm          test AL,1                                     /* Wait horizontal ON*/
  1074. asm          JNZ waith                                     /* retrace*/
  1075.  
  1076. asm          CLI                                           /* No interrupts now*/
  1077. waitv:
  1078. asm          IN AL,DX                                      /* Get 6845 status again*/
  1079. asm          and AL,AH                                     /* Wait horizonal OFF*/
  1080. asm          JZ waitv                                      /* retrace*/
  1081.  
  1082. asm          MOV AX,BX                                     /* Move word back to AX...*/
  1083. asm          STOSW                                         /* and then to screen*/
  1084. asm          STI                                           /* Allow interrupts!*/
  1085. asm          loop nextchar
  1086. asm          pop ds                                        /* RESTORE DS*/
  1087. }/* end of output*/
  1088.  
  1089. /****************************************************************************/
  1090. /*  used by window                                                          */
  1091. /****************************************************************************/
  1092.  
  1093. fscreen(int far * dest,int far *sour,int times)
  1094. {
  1095. asm          push ds                                       /* SAVE DS*/
  1096. asm          LES DI,dest                                   /* ES:DI IS DEST*/
  1097. asm          lds si,sour                                   /* DS:SI IS SOUR*/
  1098. asm          mov cx,[times]
  1099. asm          CLD                                           /* Set direction to forward*/
  1100. asm          MOV DX,03DAH                                  /* Point DX to CGA status port*/
  1101. nextchar:
  1102. asm          CLI                                           /* No interrupts now*/
  1103. asm          LODSW                                         /* and then to screen*/
  1104. asm          STOSW                                         /* and then to screen*/
  1105. asm          STI                                           /* Allow interrupts!*/
  1106. asm          loop nextchar                                 /* LOOP IF MORE*/
  1107. asm          pop ds                                        /* RESTORE DS*/
  1108. }/* end of output*/
  1109.